#ifndef _TEVENTLOOP_H_
#define _TEVENTLOOP_H_
#include <map>
#include <vector>
#include "tnocopyable.h"
#ifdef WIN32
#include <windows.h>
#else
#include <unistd.h>
#include <sys/epoll.h>
#define MAX_EVENTS 10240
#endif

namespace tlib
{
	class TSocket;
	class TServer;
	class TEventLoop : TNoCopyable
	{
	public:
		TEventLoop();
		virtual ~TEventLoop();

		bool AddLoop(TSocket* sock);
		bool DelLoop(TSocket* sock);
		void RunLoop(TServer* server);
	private:
#ifdef WIN32
		std::map<int, TSocket*> cliMap;
		fd_set connSet_, sendSet_, recvSet_;
#else
		int epollfd_;
		struct epoll_event ev_, events_[MAX_EVENTS];
#endif
	};
}

#endif